import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import {render} from "@apps/antd-admin/src/hooks/render/renderUtils";
import {RenderType} from '@pkg/setting';
import {Api} from "./api";
export const columns: BasicColumn[] = [
  {
    title: '物品编号',
    dataIndex: 'lostNo',
    width: 150,
  },
  {
    title: '物品名称',
    dataIndex: 'lostName',
    width: 180,
    customRender: render.renderTxt,
  },
  {
    title: '类别',
    dataIndex: 'lostTypeId',
    dictCode: 'lostType',
    customRender: render.renderDict,
    width: 100,
  },
  {
    title: '拾捡日期',
    dataIndex: 'lostDate',
    width: 100,
  },
  {
    title: '拾捡地',
    dataIndex: 'lostAddress',
    width: 100,
  },
  {
    title: '图片',
    dataIndex: 'lostImage',
    width: 70,
    customRender: render.renderImage,
  },
  {
    title: '状态',
    dataIndex: 'lostState',
    width: 120,
    dictData: [
      { label: '未认领', value: 0, color: '#a6a9a6' },
      { label: '已认领', value: 1, color: '#09d550' }
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 150,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'lostName',
    label: '物品名称',
    component: 'Input',
    colProps: { span: 3 },
  },
  {
    label: '物品类型',
    field: 'lostTypeId',
    component: 'ApiSelect',
    componentProps: {
      dictCode: 'lostType'
    },
  },
  {
    field: 'lostState',
    label: '认领状态',
    component: 'Select',
    colProps: {span: 3},
    componentProps: {
      options: [
        {label: '未认领', value: 0},
        {label: '已认领', value: 1},
      ],
    }
  }
];

export const formSchema: FormSchema[] = [
  {
    label: '',
    field: 'lostId',
    component: 'Input',
    show: false,
  },
  {
    label: '物品名称',
    field: 'lostName',
    component: 'Input',
    required: true,
  },
  {
    label: '物品类型',
    field: 'lostTypeId',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: Api.listByDictType,
      labelField: 'dicDataTitle',
      valueField: 'dicDataValue',
    },
  },
  {
    label: '拾捡日期',
    field: 'lostDate',
    component: 'DatePicker',
    required: true,
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    label: '拾捡地址',
    field: 'lostAddress',
    component: 'Input',
    required: true,
  },
  {
    label: '认领人',
    field: 'claimUserName',
    component: 'Input',
    ifShow: ({ values }) => {
      return !!values.lostId;
    },
  },
  {
    label: '认领人电话',
    field: 'claimUserMobile',
    component: 'Input',
    ifShow: ({ values }) => {
      return !!values.lostId;
    },
  },
  {
    label: '认领时间',
    field: 'claimDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
    ifShow: ({ values }) => {
      return !!values.lostId;
    },
  },
  {
    label: '物品图片',
    field: 'lostImage',
    component: 'ImageUpload',
  }
];
